/*
 * @Author: CodeHare
 * @Date: 2023-10-30 10:51:56
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-04-23 15:16:54
 * @Description: EMS参数设置之能量管理
 */
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:yt_devops/resources/str_res_keys.dart';

class EnergyManagementModel {}

class PeakShaveValleyFillTimeItem {
  /// 时段标题
  String label;

  /// 开始时间对象
  DateTime? startDateTime;

  /// 结束时间对象
  DateTime? endDateTime;

  /// 开始时间时分
  String startTime;

  /// 结束时间
  String endTime;

  /// 状态
  String status;

  /// 固定功率值
  String fixedPower;

  /// 固定功率控制器
  TextEditingController? textEditingController;

  /// 单位
  String unit;

  PeakShaveValleyFillTimeItem(
    this.label,
    this.startDateTime,
    this.endDateTime,
    this.startTime,
    this.endTime,
    this.status,
    this.fixedPower,
    this.textEditingController,
    this.unit,
  );
}

class SelfDevelopEMSServicesModel {
  /// 手动模式设置
  static Map<String, dynamic> manualModeMap = {
    "accessType": "push",
    "groupName": "",
    "id": "ManualModeSetting",
    "name": ResKey.deviceManualModeSetting.tr,
    "outputData": [
      {
        "dataType": {
          "specs": {
            "max": 10000000000,
            "min": 0,
            "step": 0.1,
            "unit": "kW",
            "unitName": ResKey.kilowatt.tr
          },
          "type": "double"
        },
        "id": "ChargingPower",
        "name": ResKey.deviceChargingPower.tr
      },
      {
        "dataType": {
          "specs": {
            "max": 10000000000,
            "min": 0,
            "step": 0.1,
            "unit": "kW",
            "unitName": ResKey.kilowatt.tr
          },
          "type": "double"
        },
        "id": "DischargePower",
        "name": ResKey.deviceDischargePower.tr
      }
    ]
  };

  /// 削峰填谷模式设置
  static Map<String, dynamic> peakShavingAndValleyFillingModeMap = {
    "accessType": "push",
    "groupName": "",
    "id": "PeakShavingAndValleyFillingModeSetting",
    "name": ResKey.devicePeakShavingValleyFillingModeSetting.tr, //  "削峰填谷模式设置",
    "outputData": [
      {
        "dataType": {
          "specs": {"max": 100, "min": 0, "unit": "%", "unitName": "百分比"},
          "type": "double"
        },
        "id": "peakShavingAndValleyFillingModeMaximumSOC",
        "name": ResKey.deviceMaxSoc.tr, // "最高SOC"
      },
      {
        "dataType": {
          "specs": {"max": 100, "min": 0, "unit": "%", "unitName": "百分比"},
          "type": "double"
        },
        "id": "peakShavingAndValleyFillingModeLowestSOC",
        "name": ResKey.deviceMinSoc.tr, //"最低SOC"
      },
      {
        "accessType": "push",
        "dataType": {
          "specs": {
            "item": {
              "specs": [
                {
                  "dataType": {
                    "specs": {"length": 11},
                    "type": "timeRange"
                  },
                  "id": "pcsRunningTimeFrame",
                  "name": ResKey.deviceTimePeriod.tr //时段
                },
                {
                  "dataType": {
                    "specs": {
                      "0": ResKey.thingsCharge.tr, //充电.tr,
                      "1": ResKey.thingsDischarge.tr
                    },
                    "type": "enum"
                  },
                  "id": "CorD",
                  "name": ResKey.deviceWorkMode.tr //工作模式
                },
                {
                  "dataType": {
                    "specs": {
                      "max": 10000000000,
                      "min": 0,
                      "unit": "kW",
                      "unitName": ResKey.kilowatt.tr
                    },
                    "type": "double"
                  },
                  "id": "executionPower",
                  "name": 'siteMonitor.executionPower'.tr, // "执行功率"
                }
              ],
              "type": "struct"
            },
            "size": 10
          },
          "type": "array"
        },
        "groupName": "",
        "id": "PeriodOfTime",
        "name": ResKey.deviceTimePeriod.tr
      }
    ]
  };

  ///备电模式设置
  static Map<String, dynamic> backupPowerModeMap = {
    "accessType": "push",
    "groupName": "",
    "id": "BackupPowerModeSetting",
    "name": ResKey.deviceBackupPowerModeSetting.tr, // "备电模式设置",
    "outputData": [
      {
        "dataType": {
          "specs": {
            "max": 10000000000,
            "min": 0,
            "step": 0.1,
            "unit": "kW",
            "unitName": ResKey.kilowatt.tr
          },
          "type": "double"
        },
        "id": "BackupChargingPower",
        "name": ResKey.deviceChargingPower.tr, // "充电功率"
      },
      {
        "dataType": {
          "specs": {
            "max": 10000000000,
            "min": 0,
            "step": 0.1,
            "unit": "kW",
            "unitName": ResKey.kilowatt.tr
          },
          "type": "double"
        },
        "id": "BackupDischargePower",
        "name": ResKey.deviceDischargePower.tr, // "放电功率"
      },
      {
        "dataType": {
          "specs": {
            "max": 100,
            "min": -100,
            "step": 0.1,
            "unit": "%",
            "unitName": "百分比"
          },
          "type": "double"
        },
        "id": "BackupHighestSOC",
        "name": ResKey.deviceMaxSoc.tr, // "最高SOC"
      },
      {
        "dataType": {
          "specs": {
            "max": 100,
            "min": -100,
            "step": 0.1,
            "unit": "%",
            "unitName": "百分比"
          },
          "type": "double"
        },
        "id": "BackupMinimumSOC",
        "name": ResKey.deviceMinSoc.tr, // "最低SOC"
      }
    ]
  };

  /// 尖峰平谷时段设置- 价格设置
  static Map<String, dynamic> peakAndValleyPriceMap = {
    "accessType": "push",
    "groupName": "",
    "id": "PeakAndValleyTimeSettings",
    "name": ResKey.devicPeakAndValleyTimeSetting.tr,
    "outputData": [
      {
        "dataType": {
          "specs": {
            "max": 10000000000,
            "min": 0,
            "step": 0.1,
            "unit": "${ResKey.yuan.tr}/kWh",
            "unitName": "元/千瓦时"
          },
          "type": "double"
        },
        "id": "SharpElectrovalence",
        "name": 'siteMonitor.set.SharpElectricityPrice'.tr, // "尖电价"
      },
      {
        "dataType": {
          "specs": {
            "max": 10000000000,
            "min": 0,
            "step": 0.1,
            "unit": "${ResKey.yuan.tr}/kWh",
            "unitName": "元/千瓦时"
          },
          "type": "double"
        },
        "id": "PeakElectrovalence",
        "name": 'siteMonitor.set.PeakElectricityPrice'.tr
      },
      {
        "dataType": {
          "specs": {
            "max": 10000000000,
            "min": 0,
            "step": 0.1,
            "unit": "${ResKey.yuan.tr}/kWh",
            "unitName": "元/千瓦时"
          },
          "type": "double"
        },
        "id": "FlatElectrovalence",
        "name": 'siteMonitor.set.AverageElectricityPrice'.tr
      },
      {
        "dataType": {
          "specs": {
            "max": 10000000000,
            "min": 0,
            "step": 0.1,
            "unit": "${ResKey.yuan.tr}/kWh",
            "unitName": "元/千瓦时"
          },
          "type": "double"
        },
        "id": "ValleyElectrovalence",
        "name": 'siteMonitor.set.ValleyElectricityPrice'.tr
      },
    ]
  };

  /// 尖峰平谷时段设置- 时段设置
  static Map<String, dynamic> peakAndValleyTimeMap = {
    "accessType": "push",
    "groupName": "",
    "id": "PeakAndValleyTimeSettings",
    "name": ResKey.devicPeakAndValleyTimeSetting.tr, // "尖峰平谷时段设置",
    "outputData": [
      {
        "accessType": "",
        "dataType": {
          "specs": {
            "item": {
              "specs": [
                {
                  "dataType": {
                    "specs": {"length": 11},
                    "type": "timeRange"
                  },
                  "id": "TimeFrame",
                  "name": ResKey.deviceTimePeriod.tr, //  "时段"
                },
                {
                  "dataType": {
                    "specs": {
                      "0": ResKey.thingsSetSharp.tr,
                      "1": ResKey.thingsSetPeak.tr,
                      "2": ResKey.thingsSetAverage.tr,
                      "3": ResKey.thingsSetValley.tr
                    },
                    "type": "enum"
                  },
                  "id": "ElectrovalenceType",
                  "name": ResKey.deviceElectricityPriceType.tr, //"电价类型"
                }
              ],
              "type": "struct"
            },
            "size": 10
          },
          "type": "array"
        },
        "groupName": "",
        "id": "ElectrovalenceTimeFrame",
        "name": "电价时段"
      }
    ]
  };
}

class ElectrovalenceModel {
  int electrovalenceType;
  String timeFrame;
  ElectrovalenceModel(
      {required this.electrovalenceType, required this.timeFrame});

  factory ElectrovalenceModel.fromJson(Map<String, dynamic> json) =>
      ElectrovalenceModel(
          electrovalenceType: json['ElectrovalenceType'],
          timeFrame: json['TimeFrame']);
}
